<?php
/**
 * Created by PhpStorm.
 * User: CYJiao
 * Date: 6/22/15
 * Time: 09:15
 */

class NewsController extends Controller
{

    /**
     * Method returning filters array.
     */
    public function filters()
    {
        return array(
            'accessControl',//Performs access control for CRUD operations
        );
    }

    /**
     * Defines User Access Level.
     */
    public function accessRules()
    {
        return array(
            array('allow',
                'actions'=>array(),//Actions allowed
                'roles'=>array('@'),//Roles allowed to perform actions
            ),
            array('deny',
                'actions'=>array(),//Actions not allowed
                'roles'=>array('*'),//Roles not allowed to perform actions
            ),
        );
    }

    /**
     * Declares class-based actions.
     */
    public function actions(){
        return array(
            // captcha action renders the CAPTCHA image displayed on the contact page
            'captcha'=>array(
                'class'=>'CCaptchaAction',
                'height'=>37,
                'minLength'=>4,
                'maxLength'=>6,
                'backColor'=>0xFFFFFF,
            ),
            // page action renders "static" pages stored under 'protected/views/site/pages'
            // They can be accessed via: index.php?r=site/page&view=FileName
            'page'=>array(
                'class'=>'CViewAction',
            ),
        );
    }

    /******************************************************************************************
     * Following functions are related to News
     ******************************************************************************************/

    /**
     * Getting News Content Index
     */
    public function actionGetNews(){
        if(isset(Yii::app()->session['status']) && Yii::app()->session['status'] == 'logged') {
           $newid = $_GET['newid'];
           $this->render('newsindex'.$newid);
        }
        else
            $this->redirect(array('site/login'));// View redirection
    }



}
